const program = require("commander")
const { createProjectAction, addComponentAction, addPageAndRouteAction, addStoreAction, translationWordAction, commitToGitAction } = require("./actions")

const createCommands = () => {
  program
    .command("create <project> [otherArgs...]")
    .description('克隆vue代码模板')
    .action(createProjectAction)

  program
    .command("addcpn <name>")
    .description("创建一个vue组件, 例如: lwj addcpn HelloWorld -d [src/components]")
    .action(name => addComponentAction(name, program._optionValues.dest || "src/components"))

  program
    .command("addpage <page>")
    .description("添加vue页面和路由, 例如: lwj addpage Home [-d src/pages]")
    .action(page => addPageAndRouteAction(page, program._optionValues.dest || `src/pages`))

  program
    .command("addstore <store>")
    .description("新建一个 vuex store仓库, 例如: lwj addstore home [-d src/store/modules/home]")
    .action(store => addStoreAction(store, program._optionValues.dest || `src/store/modules`))

  program
    .command("f [word...]")
    .description("快速翻译, 例如: lwj f hello")
    .action(word => translationWordAction(word, program._optionValues.in, program._optionValues.out))

  program
    .command("push [word...]")
    .description("git 上传代码, 例如: lwj push 完成动态页面")
    .action(word => commitToGitAction(word || "update", program._optionValues.dest || "update"))
}

module.exports = createCommands
